<template>
	<div>

		<seller-tap>
			<span slot='font'>收货地址</span>
			<a :href="target" class="fa fa-chevron-left" slot='a'></a>
		</seller-tap>
		<form @submit="submit">
			<div>
				<span>收货人</span><input type="text" v-model="name" />
			</div>
			<div>
				<span>联系电话</span><input type="text" v-model="tel" />
			</div>
			<div>
				
				
				

				<div>
				
					<x-address style="padding:0;border: none;" title='所在地区'  @on-hide="logHide" placeholder="请选择地址"  :list='addressData'>
					
				</x-address>
		
				</div>
				
			</div>
			<div class="textarea">
				<textarea name="more" v-model="more" placeholder="详细地址" rows="3" cols="43"></textarea>
			</div>
			<button type="submit">保存</button>
		</form>
	</div>
</template>

<script>
	import $ from 'jquery';
	import axios from 'axios'
	import SellerTap from '../components/SellerTap'
	import { Group, XAddress, ChinaAddressV4Data, XButton, Cell, Value2nameFilter as value2name } from 'vux'
	export default {
		data: function() {
			return {
				name: '',
				tel: '',
				more: '',
				areaList:'',
				target:'',
				addressData: ChinaAddressV4Data,
			

			}
		},
		components: {

			SellerTap,
			XAddress,

		},
		methods: {
			submit(ev) {
				ev.preventDefault();
				var data = {
					name:this.name,
					phone:this.tel,
					area:this.areaList+this.more,
					check:false,
					index:false,
				}
				axios.post('/buller/addArea',data).then((result)=>{
					if(result.data == 'success'){
						location.href = this.target
					}
				}).catch((err)=>{
					console.log(err);
				})
			},
			logHide(ev){
				var area = $('.vux-popup-picker-value').text();
				area = area.split(' ');
				var b = '';
				for(var i = 0;i<area.length;i++){
					
					b+=area[i];
				}
							
				this.areaList = b;
			}
		},
		mounted(){
			if(this.$route.query.car){
				this.target = '#/buller/area?car=ee'
			}else if(this.$route.query.id){
				this.target = '#/buller/area/?num='+this.$route.query.num+'&model='+this.$route.query.model+'&color='+this.$route.query.color+'&id='+this.$route.query.id;
			}else{
				this.target = '#/buller/area'
			}
		}
	}
</script>

<style scoped>
	
	form>div{
		font-size: 14px;
		color: #333;
		overflow: hidden;
		padding: 7px 15px;
		border-bottom: solid 1px #EEEEEE;
		line-height: 25px;
	}
	form>div span{
		float: left;
		width: 20%;
		
	}
	form>div input{
		width: 80%;
		border: none;
		line-height: 25px;
	}
	form div:nth-child(3){
		padding: 0;
	}
	form div:nth-child(3) div{
		
		width: 100%;
	}
	.vux-tap-active {
		border-top: none;
	}
	form div:nth-child(3) div .vux-cell-box .weui-cell:before{
		border-top-color: white;
	}
	form>div.textarea{
		padding: 0;
		border-bottom: none;
	}
	form textarea{
		border: solid 1px #EEEEEE;
		font-size: 14px;
		width: 104%;
		padding: 3%;
	}
	form button{
		border: none;
		width: 100%;
		/*margin-left: 10%;*/
		line-height: 35px;
		font-size: 15px;
		margin-top: 30px;
		background: linear-gradient(to right,#FF8800 10%,#FF5500 80%);
		color: white;
	}
</style>